import time

from public.action import *
from public.business import *
from public.testData import *
from public.tools import *

testCase = "dbshopST006_删除订单"
#打开网址
firefox = openBrowser(urlAdmin)
#登陆
DBshopLoginAdmin(firefox)
#进入二级菜单
DBshopEnterMenu2(firefox, '销售管理', '订单管理')
#筛选已取消订单
firefox.find_element_by_xpath('//select[@id="order_state"]/option[2]').click()
#点击搜索
firefox.find_element_by_xpath('(//button[@type="submit"])[1]').click()
#点击编辑查看
firefox.find_element_by_link_text('编辑查看').click()
#查询订单编码
order=reGetString((firefox.find_element_by_xpath('//strong').text),'订单 ',' |')
print(order)
#删除订单
firefox.find_element_by_link_text('删除订单').click()
#处理js弹窗
firefox.switch_to.alert.accept()
#严重订单是否被删除
firefox.find_element_by_xpath('(//input[@class="span11"])[1]').send_keys(order)
firefox.find_element_by_xpath('(//button[@type="submit"])[1]').click()
#断言
try:
    firefox.find_element_by_xpath('//td[text()="order"]')
    writeLog("%s 测试失败" % testCase)
except:
    writeLog("%s 测试通过" % testCase)
    getPhoto(firefox)
firefox.quit()